import { defineConfig,loadEnv ,ConfigEnv,UserConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import path from "path"
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import Icons from "unplugin-icons/vite";
import IconsResolver from "unplugin-icons/resolver";
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import UnoCSS from 'unocss/vite'
import glsl from 'vite-plugin-glsl';
const pathSrc = path.resolve(__dirname,"src")
export default defineConfig(({ mode }: ConfigEnv): UserConfig=>{
  const env = loadEnv(mode,process.cwd())
  return {
  resolve:{
    alias:{
      "@": pathSrc
    }
  },
  css: {
    preprocessorOptions: {
        scss: {
            javascriptEnabled: true,
            additionalData: `@use "@/styles/variables.scss" as *;`
        }
    }
  },
  plugins: [
    vue(),
    glsl(),
    AutoImport({
      imports: ["vue"],
      eslintrc: {
        enabled: true, 
        filepath: "./.eslintrc-auto-import.json", 
      },
      dts: path.resolve(pathSrc, "types", "auto-imports.d.ts"), 
    }),
    Components({
      resolvers: [
        ElementPlusResolver(),
        IconsResolver({
          enabledCollections: ["ep"] 
        }),
      ],

      dts: path.resolve(pathSrc, "types", "components.d.ts"), 
    
    }),
    Icons({
      autoInstall: true,
    }),
    createSvgIconsPlugin({
      iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
      symbolId: 'icon-[dir]-[name]',
  }),
   UnoCSS({ /* options */ }),
],
  base:'./',
  server:{
    host:"0.0.0.0",
    open:true, 
    port:5174
 /*    proxy:{
      '/api':{
        target:"http://192.168.5.71:8895",
        changeOrigin:true,
        rewrite:(path)=>path.replace(/^\/api/,''),
      }
    } */
}}})

